<%@ Page Title="Candidates" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
    AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<IPagination<ETestIT.Core.Candidate>>" %>

<%@ Import Namespace="MvcContrib.UI.Pager" %>
<%@ Import Namespace="MvcContrib.Pagination" %>
<%@ Import Namespace="ETestIT.Web.Presentation" %>
<%@ Import Namespace="MvcContrib.UI.Grid" %>
<%@ Import Namespace="ETestIT.Core" %>
<%@ Import Namespace="ETestIT.Web.Controllers" %>
<%@ Import Namespace="MvcContrib.UI.Grid.ActionSyntax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentTitlePlaceHolder" runat="server">
    <h2>
        Candidates</h2>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

    <% if (ViewContext.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] != null)
       { %>
    <p id="pageMessage">
        <%= ViewContext.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()]%></p>
    <% } %>
    <div>
        <%= Html.ActionImage<CandidatesController>(c => c.Create(), "content/images/add.ico", "Create New Candidate", null, null, new { @class = "add" })%>
        <a href="#" class="search"><%= Html.Image("~/Content/Images/search.ico")%></a>
        <% Html.Grid(Model).Columns(column =>
        {
            column.For(x => x.FirstName);
            column.For(x => x.Surename);
            column.For(x => x.Email);
            column.For(x => x.Phone);
            column.For(x => x.Category);
            column.For(x => x.ProfileTitle.Name);
            column.For(x => x.RecrutedBy);
            column.For(x => Html.ActionImage<CandidateResumesController>(c => c.Index(x.Id), "content/images/document.ico", "Resumes")).Named("Resumes").DoNotEncode();
            column.For("Actions").Named("Actions").Action(p =>
                   {%><td>
                   <%  var fid = Guid.NewGuid();
                       using (Html.BeginForm<CandidatesController>(c => c.Delete(p.Id), FormMethod.Post, new { id = fid }))
                       { %><%= Html.AntiForgeryToken()%>
                   <%=Html.ActionImage<CandidatesController>(c => c.Show(p.Id), "content/images/view.ico", "Details ")%>
                   <%=Html.ActionImage<CandidatesController>(c => c.Edit(p.Id), "content/images/edit.ico", "Edit")%>
                   <a href="#" onclick="ConfirmeDialog('<%= fid %>'); return false;">
                       <img src="content/images/delete.ico" alt="" /></a>
                   <% } %>
               </td>
        <%});
        }).Attributes(@class => "grid", width => 770).RenderUsing(new FooterTableGridRender<Candidate>()).Render();%>
        <br />
        <%= Html.Pager(Model) %>
    </div>
    <% Html.RenderPartial("SearchForm"); %>
</asp:Content>
